package com.cskaoyan.controller.wxcontroller;

import com.cskaoyan.bean.pojo.User;
import com.cskaoyan.bean.vo.BaseRespVo;
import com.cskaoyan.bean.vo.GoodsDetailVo;
import com.cskaoyan.bean.vo.wx.BrandDetailVO;
import com.cskaoyan.bean.bo.GoodsCategoryBO;
import com.cskaoyan.bean.vo.*;
import com.cskaoyan.service.GoodsService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: thz
 * @class: GoodsController
 */
@RestController("wxGoodsController")
@RequestMapping("/wx/goods")
public class GoodsController {

    @Autowired
    GoodsService goodsService;

    @RequestMapping("count")
    public BaseRespVo wxGoodsCount(){
        GoodsCountVO goodsCountVO=goodsService.queryGoodsCount();
        return BaseRespVo.ok(goodsCountVO);
    }

    @RequestMapping("list")
    public BaseRespVo wxGoodsCategory(GoodsCategoryBO goodsCategoryBO){
        Subject subject = SecurityUtils.getSubject();
        User user = (User) subject.getPrincipal();
        WxGoodsListVO wxGoodsListVO = goodsService.queryWxGoodsList(goodsCategoryBO,user);
        return BaseRespVo.ok(wxGoodsListVO);
    }

    @RequestMapping("category")
    public BaseRespVo wxGoodsList(Integer id){
        GoodsCategoryVO goodsCategoryVO = goodsService.queryWxGoodsCategory(id);
        return BaseRespVo.ok(goodsCategoryVO);
    }

    /**
     * @author: thz
     * @title: wxGoodsDetail
     * @description: 商品id
     * @param: [id]
     * @return: com.cskaoyan.bean.vo.BaseRespVo
     */
    @RequestMapping("detail")
    public BaseRespVo wxGoodsDetail(Integer id){
        WxGoodsDetailVO wxGoodsDetailVO = goodsService.queryWxGoodsDetail(id);
        return BaseRespVo.ok(wxGoodsDetailVO);
    }

    @RequestMapping("related")
    public BaseRespVo wxGoodsRelated(Integer id){
        WxGoodsRelatedVo wxGoodsRelatedVo=goodsService.queryRelatedGoods(id);
        return BaseRespVo.ok(wxGoodsRelatedVo);
    }


}
